package school30.io.memory;

import school30.io.*;

public class MemoryFileConnector extends FileConnector{
    protected MemoryFileStorage storage = new MemoryFileStorage();

    public MemoryFileConnector(MemoryFileStorage st)
    {
        this.storage = st;
    }

    public FileReader openRead(File path) {
        return new MemoryFileReader(storage, path);
    }

    public FileWriter openWrite(File path) {
        return new MemoryFileWriter(storage, path, 1024);
    }

    public long size(File path) {
        return storage.size(path);
    }

    public void deleteFile(File path) {
        storage.deleteFile(path);
    }

    public void createFolder(File path) {
        storage.createFolder(path);
    }

    public boolean isFolder(File path) {
        return size(path) == -2;
    }

    public String[] folderContents(File path) {
        return storage.folderContent(path);
    }
}
